using UnityEngine;
using System.Collections;

public class Redimension : MonoBehaviour {
	
	public Texture2D texture;
	public GameObject go;
	
	private float xRatio;
	private float yRatio;
	
	void Start () {
	
		xRatio = (3 * Camera.mainCamera.orthographicSize) / 540;
		yRatio = (2 * Camera.mainCamera.orthographicSize) / 380;
		
		float xScale = this.texture.width * this.xRatio;
		float yScale = this.texture.height * this.yRatio;
		
		this.go.transform.localScale = new Vector3(xScale, yScale, go.transform.localScale.z);
	}
	
	void Update () {
	
	}
	
	public static void Resize(Texture2D tex, GameObject go)
	{
		float xRatio = (3 * Camera.mainCamera.orthographicSize) / 540;
		float yRatio = (2 * Camera.mainCamera.orthographicSize) / 380;
		
		float xScale = tex.width * xRatio;
		float yScale = tex.height * yRatio;
		
		go.transform.localScale = new Vector3(xScale, yScale, go.transform.localScale.z);
	}
}
